//
//  UIBarButtonItem+DZExtension.m
//  Weico
//
//  Created by 大泽 on 15/7/21.
//  Copyright (c) 2015年 刘洪泽. All rights reserved.
//

#import "UIBarButtonItem+DZExtension.h"

@implementation UIBarButtonItem (DZExtension)

+ (UIBarButtonItem *)itemWithTarger:(id)targer action:(SEL)action title:(NSString *)title image:(NSString *)imageName highImage:(NSString *)highImage{
    
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    
    UIImage *image = [UIImage imageNamed:imageName];
    UIImage *highLightImage = [UIImage imageNamed:highImage];
    
    if (image || highImage) {
        [btn setImage:image forState:UIControlStateNormal];
        [btn setImage:highLightImage forState:UIControlStateHighlighted];
    }
    
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    
    [btn addTarget:targer action:action forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:btn];
    
    return item;
}

@end
